﻿#ifndef FORMPRINTER_H
#define FORMPRINTER_H

#include "formadvancedsearch.h"
#include "qpainter.h"
#include "workorder.h"
#include <MyPrinterFun.h>
#include <QApplication>
#include <QProcess>
#include <QStandardItemModel>
#include <QWidget>
#include "myrowdelegate.h"
#include "mytableview.h"

namespace Ui {
class FormPrinter;
}

class MyProcess;
/* 铭牌/条码打印界面 */
class FormPrinter : public QWidget
{
    Q_OBJECT

public:
    explicit FormPrinter(QWidget *parent = nullptr);
    ~FormPrinter();
    void InitTableData(QString filePath);

signals:
    void slot_reset_export_data_method(int ed_method);
    void slot_reset_print_method(int ed_method);


private slots:
    void on_spinBox_valueChanged(int arg1);
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_lineEdit_textChanged(const QString &arg1);

    void on_pushButton_3_clicked();

    void finished(int exitCode, QProcess::ExitStatus exitStatus);

    void on_checkBox_stateChanged(int arg1);

    void slot_switch_combox(QString filter, QString data);

    void on_lineEdit_2_textChanged(const QString &arg1);

    void on_tableViewCustomContextMenuRequested(const QPoint &pos);

    void on_comboBox_currentTextChanged(const QString &arg1);

    void on_lineEdit_returnPressed();

protected:
    void keyPressEvent(QKeyEvent *event) override;
public:
    QString bartend_exe="C:\\Program Files (x86)\\Seagull\\BarTender Suite\\bartend.exe";
    QString bylabel_exe="C:\\Program Files\\BYLabel\\BYLabel.exe";
    void updateCombox();
    void switchCombox(QString filePath);
    void SearchAll();
    Ui::FormPrinter *ui;
    MyProcess *runexe;
    WorkOrder *workOrder;
    MyPrinterFun myPrinterFun;
    int ExportData(bool isSaveLog=false, bool isGetNoneSelected=false, bool isGetHiddened=false);
    void setDataMethod(int val);
    void setPrintMethod(int val);
    int getDataMethod(){return data_method;};
    int getPrintMethod(){return print_method;};
    MyTableView *getTableView();
    void printTbText(int all_rows, int not_hidden_rows);
private:
    int data_method=0;  // 保存数据库的格式，0-xls，1-text
    int print_method=0; // 打印方式，0-Bartender，1-Bylabel
    FormAdvancedSearch *searchForm;
    QTimer *timer_combox;
    QString combo_sub;
};

#endif // FORMPRINTER_H
